Repository navigation
Read canonical test worker replies through portable pipes - #9218
loopx-agent wants to merge 3 commits into
Conversation
Signed-off-by: LoopX Agent <[email protected]>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
维护者运行真实 File/SQLite fixture 的 CLI 和 Research 回归,需要在所有支持的宿主读取可复验的结果。 共享 fixture 在匿名管道上使用 selectors。其 TimeoutError 原先进入更宽的 OSError 分支。 Research 测试通过有状态的 Node fixture 写入并读回 canonical authority。Windows 选择器拒绝进程的匿名管道,因此旧版在读回前退出。现在成功路径按完整 UTF-8 行收件,静默超时留给调用者一次明确失败。 每个子进程拥有独立的逐行回复队列和 stderr 读端。定时等待以已收到的完整行或明确失败结束。 仅涉及测试基础设施,本次独立证据为 macOS 真实 Node 管道与 socket-only 模拟。原生 Windows 资格仍独立。
改动思路 / Approach
在既有 worker 的 spawn 中装配两个单进程 reader,复用现有请求锁和一次重生规则。 超时只清理该 fixture 自己的进程。正常 EOF 可以按原调用契约重生一次,生产运行时无调用新增。 在已有可复用 fixture 修复,使所有消费者共享同一个协议和清理所有者。缺少独立 worker 的新 smoke 不会覆盖这条实际调用链。
具体改动 / Changes
准确头 7b9ccbe,merge base a6ffb3b,2 个文件,+70/-44。当前主干 b4e1ded 整合预演无冲突。逐行读取、重生与清理均在共享 worker 内。回归只增加一个真正静默的 Node 对端。 按修订 a6ffb3b 的现有规范核对各项要求。 目标规范
- process-boundary · Use the actual child pipe at the existing fixture call site.
- single-timeout · Propagate timeout once and reap the same child and readers.
- durable-regression · Keep a real non-duplicative fixture test protecting an existing consumer boundary.
关键代码讲解
- 进程作用域与读端 每次 spawn 重新创建队列和 stderr 缓存,按完整行交付。
- 截至时间与重生 超时优先终止;EOF 保留一次 fixture 重生。
- 退出与资源回收 先回收对应子进程,再收 reader 和缓冲流。
- 静默进程回归 断言原子进程不被换成新进程且已退出。
对主干的风险 / Risks
在 macOS 设置 PYTHONUTF8=0,canonical fixture 与 Research 消费者测试独立跑完,83 项通过,4 项跳过。另用实际 Node 匿名管道,在一个进程里连续读回三条大响应,写端刻意在 UTF-8 字符中间切块。完整文本与每次请求序号一致,另让子进程收到请求后写出半行并退出,主干和当前头都只起一个新子进程,随后返回完整新回复。 以同一个只接受 socket 的 selector 替身运行旧主干和准确头。旧版注册匿名管道失败。旧版静默子进程还会错误重发,再把 TimeoutError 改成 AssertionError。当前头实测静默脚本仅收到一条请求,返回 TimeoutError,原进程退出,两条 reader 线程均结束。 精确源码 quick premerge 5 项直接检查和 3 项 catalog 都执行通过。前后对照覆盖 socket-only 和静默超时,实际本地 Research fixture 同时覆盖正常入口。 Windows 原生匿名管道行为仍需在对应宿主确认。本轮不把 socket-only 仿真当成 Windows 执行结果。
我的整体评价 / Verdict
批准。在既有 worker 的 spawn 中装配两个单进程 reader,复用现有请求锁和一次重生规则。 超时只清理该 fixture 自己的进程。正常 EOF 可以按原调用契约重生一次,生产运行时无调用新增。 批准准确头。共享改动解除 fixture 的 socket-only 依赖,收紧静默请求的重放边界,保留退出后重生和实际 File/SQLite 消费者路径。生产入口未引入新 worker。
English verdict: APPROVE at 7b9ccbe. Approve the exact head for the test-only transport repair. Real local pipes preserved split UTF-8 replies and a silent child was reaped after one request. Native Windows qualification is still separate.
Signed-off-by: LoopX Agent <[email protected]>
Signed-off-by: LoopX Agent <[email protected]>
Goal and scope
The Windows research fixture tests fail before they can read the saved results. Python's Windows selector rejects the canonical test worker's anonymous stdout pipe with WinError 10038. Both #9204 and #9200 reproduced that failure in four research fixtures.
The worker reads complete UTF-8 response lines through a thread and a queue owned by the child process. It retains the response deadline and recovery for an exited child. Child shutdown and the output readers share one cleanup deadline. Each reader closes its stream when the pipe is released, so a descendant holding the old pipes cannot block the timeout or a later request to a replacement worker.
Validation
Tested commit
843e531cf7ef9791c122f398b83c60c3876eae80against main atb4e1ded.7b9ccbe, the caller remained blocked in cleanup after the request deadline. The current commit delivers the timeout and accepts a request through a new worker while both old pipes are still held. Releasing the descendant closes both old streams.